package com.gao.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class Receive1 {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(3333);
        System.out.println("聊天室开启");
        while (true) {
            DatagramPacket packet =new DatagramPacket(new byte[1024],1024);
            socket.receive(packet);
            byte[] data = packet.getData();
            String msg = new String(data,0,packet.getLength());
            System.out.println(msg);
        }
    }
}
